<template>
  <div :class="[`nav-theme-${navTheme}`, `nav-layout-${navLayout}`]">
    <a-layout style="min-height: 100vh">
      <a-layout-sider
        v-if="navLayout === 'left'"
        :theme="navTheme"
        :trigger="null"
        collapsible
        v-model="collapsed"
        width="256px"
      >
        <div class="logo" @click="$router.push('/')">
          TRCBSCETH
        </div>
        <SiderMenu :theme="navTheme" :collapsed="collapsed" />
      </a-layout-sider>
      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <a-icon
            v-auth="['admin']"
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="collapsed = !collapsed"
          ></a-icon>
          <Header />
        </a-layout-header>
        <a-layout-content style="margin: 16px 16px 0">
          <!-- <tag-navs /> -->
          <router-view></router-view>
        </a-layout-content>
        <a-layout-footer style="text-align: center">
          <Footer />
        </a-layout-footer>
      </a-layout>
    </a-layout>
    <!-- <Authorized :authority="['admin']">
        <SettingDrawer />
      </Authorized> -->
  </div>
</template>

<script>
import Header from "./Header";
import Footer from "./Footer";
import SiderMenu from "./SiderMenu";
import { mapActions } from "vuex";
// import SettingDrawer from "../components/SettingDrawer";

export default {
  data() {
    return {
      collapsed: false
    };
  },
  computed: {
    navTheme() {
      return this.$route.query.navTheme || "dark";
    },
    navLayout() {
      return this.$route.query.navLayout || "left";
    }
  },
  watch: {
    $route: {
      immediate: true,
      handler(val) {
        const { name, meta, fullPath, path } = val;

        this.setTagNavs({
          name,
          meta,
          fullPath,
          path
        });
      }
    }
  },
  methods: {
    ...mapActions(["setTagNavs"])
  },
  components: {
    Header,
    Footer,
    SiderMenu
    // SettingDrawer
  }
};
</script>

<style scoped lang="less">
.trigger {
  padding: 0 20px;
  line-height: 64px;
  font-size: 20px;

  &:hover {
    background: @primary-1;
  }
}

.logo {
  position: relative;
  height: 64px;
  padding-left: 4px;
  overflow: hidden;
  line-height: 64px;
  cursor: pointer;

  img {
    width: 160px;
    max-width: 1000%;
  }

  color: white;
  font-weight: bold;
  text-align: center;
  font-size: 16px;
}

.nav-theme-dark {
  /deep/ .logo {
    h1 {
      color: #ffffff;
    }
  }
}

.ant-layout.ant-layout-has-sider > .ant-layout,
.ant-layout.ant-layout-has-sider > .ant-layout-content {
  overflow-x: initial;
  min-width: 920px;
}
</style>
